<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTableOrder extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		//
		Schema::create('order', function($table){
			$table->bigIncrements('id');
			$table->string('name', 50);
			$table->string('email');
			$table->bigInteger('total');
			$table->bigInteger('subtotal');
			$table->string('promo_code', 30);
			$table->boolean('is_purchased')->default(0);
			$table->dateTime('purchased_date')->nullable;
			$table->bigInteger('ref_id')->unsigned()->nullable();
			$table->timestamps();
			$table->softDeletes();

			$table->index('email');
			$table->foreign('ref_id')->references('id')->on('user');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		//
	}

}
